﻿@model EWSelectionDefinition
@{
    ViewBag.Title = EWWebResources.Selection_PageTitle_Details;
}

@using (Html.BeginRouteForm("EasyWeb_Selection", new { action = "Edit" }, FormMethod.Post, new { id = "easyweb-form-edit" }))
{
    <fieldset>
        <legend></legend>
        <div>
            @Html.LabelFor(m => m.InternalName)
            @Html.TextBoxFor(m => m.InternalName, new Dictionary<string, object>() { { "readonly", "readonly" } })
        </div>
        <div>
            @Html.LabelFor(m => m.DisplayName)
            @Html.EditorFor(m => m.DisplayName)
        </div>
        <div>
            @Html.LabelFor(m => m.SelectionItems)
            @Html.EditorFor(m => m.SelectionItems)
        </div>
        <div>
            <input id="easyweb-action-submit" type="submit" value="@EWWebResources.Button_Save" />
            <input id="easyweb-action-delete" type="button" value="@EWWebResources.Button_Delete" />
            <a id="easyweb-action-cancel" href="@Url.RouteUrl("EasyWeb_Selection", new { action = "Index" })">@EWWebResources.Button_Cancel</a>
        </div>
        @Html.HiddenFor(m => m.Timestamp)
        @Html.HiddenFor(m => m.Id)
    </fieldset>
}

@using (Html.BeginRouteForm("EasyWeb_Selection", new { action = "Delete" }, FormMethod.Post, new { id = "easyweb-form-delete" }))
{
    @Html.HiddenFor(m => m.Id)
    @Html.HiddenFor(m => m.Timestamp)
}

@section head {
    <style type="text/css">
        #easyweb-form-edit label {
            display: block;
            font-weight: bold;
            margin: 1.5em 0 .5em 0;
        }
        #@Html.IdFor(m => m.InternalName) {
            width: 30em;
        }
        #easyweb-action-submit, #easyweb-action-delete, #easyweb-action-cancel {
            margin: 1.5em 0 0 0;
        }
    </style>
}

@section scripts {
    <script type="text/javascript">
        (function ($) {
            $(function () {
                EasyWeb.EWAdmin.refreshEWText("@Html.IdFor(m => m.DisplayName)");

                $("#easyweb-form-edit").submit(function () {
                    EasyWeb.EWAdmin.refreshEWText("@Html.IdFor(m => m.DisplayName)");
                });

                $("#easyweb-action-submit, #easyweb-action-delete, #easyweb-action-cancel").button();

                $("#easyweb-action-delete").click(function () {
                    @EWEasyWeb.ConfirmDialog(EWWebResources.Selection_Confirm_Delete, @<text>function () { document.forms["easyweb-form-delete"].submit(); }</text>)
                });
            });
        })(jQuery);
    </script>
}